//
// Created by 000 on 2025/5/23.
//

#ifndef GY33_GY33_I2C_H
#define GY33_GY33_I2C_H

#include "main.h"
#include "printf.h"

#define GY33_ADDR           0xb4

#define GY33_RAW_RED_H      0x00
#define GY33_RAW_RED_L      0x01
#define GY33_RAW_GREEN_H    0x02
#define GY33_RAW_GREEN_L    0x03
#define GY33_RAW_BLUE_H     0x04
#define GY33_RAW_BLUE_L     0x05
#define GY33_RAW_CLEAR_H    0x06
#define GY33_RAW_CLEAR_L    0x07

#define GY33_LUX_H          0x08
#define GY33_LUX_L          0x09
#define GY33_CT_H           0x0a
#define GY33_CT_L           0x0b

#define GY33_R              0x0c
#define GY33_G              0x0d
#define GY33_B              0x0e

#define GY33_COLOR          0x0f

#define GY33_CONFIG         0x10

#define ABS(x) (x)>0?(x):(-(x))

typedef enum{
    Red = 0,
    Yellow,
    Blue,
    Green,
    Default
}RGB_t;

typedef struct {
    uint16_t raw_R;
    uint16_t raw_G;
    uint16_t raw_B;
    uint16_t raw_C;
    uint8_t R;
    uint8_t G;
    uint8_t B;
    uint16_t Lux;
    uint16_t CT;
    uint16_t color;
}color_t;
//
//typedef struct {
//    float R;
//    float G;
//    float B;
//}color_RGB;

uint8_t gy33_GetByte(uint8_t mem_addr);
void gy33_SendConfig(uint8_t *config);
void gy33_GetData(color_t *color);
int8_t gy33_ColorIdentify();

#endif //GY33_GY33_I2C_H
